package cn.cjxy.web.servlet;


import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 基于xml配置
 * 编写一个类继承HttpServlet类
 * @author huangjie
 * @date 2025/9/26
 */
public class HelloServlet extends HttpServlet {

    /**
     *
     * @param req 请求数据
     * @param res 响应数据
     * @throws ServletException
     * @throws IOException
     */
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //设置响应编码
        resp.setContentType("text/html;charset=utf-8");
        //往网页输出信息
        //获取打印流对象
        resp.getWriter().print("<h1>hello tomcat</h1>");
    }
}
